class Solution(object):
    def largeGroupPositions(self, s):
        """
        :type s: str
        :rtype: List[List[int]]
        """
        n = len(s)
        left = 0
        right = 0
        out = []
        while right < n:
            if s[right] != s[left]:
                if right - left >= 3:
                    out.append([left, right - 1])
                left = right
            right += 1
        if right - left >= 3:
            out.append([left, right - 1])
        return out


data = Solution()
s = "abbxxxxzzy"
print(data.largeGroupPositions(s))
s = "abcdddeeeeaabbbcd"
print(data.largeGroupPositions(s))